
/**
 *  Class: Datastructures, CSI 326 Fall 2011
 *  Members: Christopher Nerf, Greg Shevach, Mesfin Solomon, Vidat Muslim
 *  Project: Project 1
 *  Scope: Implement a stack using one of the basic containers we have or will discuss. Example: A vector or list based stack.
 *  	   Implement a queue using one of the basic containers we have or will discuss. Example: A circular array or list based
 *		   queue
 *		   Develop and implement a palindrome checker that uses your stack and/or queue.
 *				 The data to be checked as a palindrome will consist of string characters, possibly containing whitespace and
 *				punctuation.
 *				 A palindrome reads the same forward as backward, ignoring case, whitespace and punctuation.
 *				 The strings to check will be stored in a file, one string per line. The file will contain the string quit to signify
 *				the end of file.
 *				 The strings can be of any length
 *  Version: 0.0 - Initial Pass
 */


//this code is unaltered and provided by the professor


import java.util.Iterator;

public class DoubleIterator<T> implements Iterator {
    private int count;              // the number of elements in the collection
    private DoubleNode<T> current;  // the current position

    /**
     * Sets up this iterator using the specified items.
     */
    public DoubleIterator( DoubleNode<T> list, int size ) {
	current = list;
	count   = size;
    }

    /**
     * Returns true if this iterator has at least one more element
     * to deliver in the iteration.
     */
    public boolean hasNext() {
	return ( current != null );
    }

    /**
     * Returns the next element in the iteration. If there are no
     * more elements in this iteration, a CSI326Exception is
     * thrown.
     */
    public T next() {
	if (! hasNext() )
	    throw new CSI326Exception( "Element does not exist" );

	T result = current.getElement();
	current  = current.getNext();
	return ( result );
    }

    /**
     * The remove operation is not supported.
     *
     */
    public void remove() throws UnsupportedOperationException {
	System.out.println( "This method is not supported" );
    }
}